Skip to content

fix(account-mapping): repair benchmark failures for EVM accounts#89

Merged
nol4lej merged 3 commits into
mainfrom
fix/account-mapping-benchmark-evm-accounts
May 22, 2026
Merged

fix(account-mapping): repair benchmark failures for EVM accounts#89
nol4lej merged 3 commits into
mainfrom
fix/account-mapping-benchmark-evm-accounts

Conversation

@nol4lej
Copy link
Copy Markdown
Member

@nol4lej nol4lej commented May 22, 2026

Three benchmarks failed when running on the Hetzner reference node:

  1. map_account / unmap_account → NativeAccountCannotBeMapped Root cause: whitelisted_caller() produces a Substrate AccountId32 whose bytes[20..32] are not [0u8; 12] (EVM_ACCOUNT_MARKER), so AccountIdToEvmAddress::convert returns None. Fix: new helper evm_account() builds an AccountId with a deterministic H160 in bytes[0..20] and [0u8;12] in bytes[20..32].

  2. dispatch_as_private_link → InvalidProof Root cause: PrivateLinkZkAdapter calls the real pallet-zk-verifier Groth16 verifier; the mock proof [0x01, 0x00, ...] fails. Fix: add a #[cfg(feature = "runtime-benchmarks")] bypass in PrivateLinkZkAdapter::verify that accepts any non-empty proof. The actual ZK pairing cost is benchmarked separately via pallet_zk_verifier::verify_proof.

Changes:

  • frame/account-mapping/src/benchmarking.rs · add evm_account() helper
    · #[benchmarks] where clause: + T::AccountId: From<[u8; 32]>
    · map_account, unmap_account: use evm_account::() as caller
  • template/runtime/src/lib.rs · PrivateLinkZkAdapter::verify: short-circuit under runtime-benchmarks

nol4lej added 3 commits May 22, 2026 13:40
Three benchmarks failed when running on the Hetzner reference node:

1. map_account / unmap_account → NativeAccountCannotBeMapped
   Root cause: whitelisted_caller() produces a Substrate AccountId32
   whose bytes[20..32] are not [0u8; 12] (EVM_ACCOUNT_MARKER), so
   AccountIdToEvmAddress::convert returns None.
   Fix: new helper evm_account<T>() builds an AccountId with a
   deterministic H160 in bytes[0..20] and [0u8;12] in bytes[20..32].

2. dispatch_as_private_link → InvalidProof
   Root cause: PrivateLinkZkAdapter calls the real pallet-zk-verifier
   Groth16 verifier; the mock proof [0x01, 0x00, ...] fails.
   Fix: add a #[cfg(feature = "runtime-benchmarks")] bypass in
   PrivateLinkZkAdapter::verify that accepts any non-empty proof.
   The actual ZK pairing cost is benchmarked separately via
   pallet_zk_verifier::verify_proof.

Changes:
- frame/account-mapping/src/benchmarking.rs
  · add evm_account<T>() helper
  · #[benchmarks] where clause: + T::AccountId: From<[u8; 32]>
  · map_account, unmap_account: use evm_account::<T>() as caller
- template/runtime/src/lib.rs
  · PrivateLinkZkAdapter::verify: short-circuit under runtime-benchmarks
@nol4lej nol4lej merged commit b734c63 into main May 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant